package com.cn.kabalifeuser.utils;

import android.annotation.SuppressLint;
import android.content.Context;
import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.bumptech.glide.request.RequestOptions;
import com.cn.kabalifeuser.R;

import java.io.File;

/**
 * Created by Lynn on 2019/8/7.
 * function:
 */

public class GlideUtil {

    @SuppressLint("CheckResult")
    public static void ImageLoad(Context context, String url, ImageView imageView) {
        RequestOptions options = new RequestOptions();
        options.error(R.drawable.item_)
                .fallback(R.drawable.item_);
        Glide.with(context)
                .load(url)
                .apply(options)
                .into(imageView);
    }
    @SuppressLint("CheckResult")
    public static void ImageLoad(Context context, int url, ImageView imageView) {
        RequestOptions options = new RequestOptions();
        options.error(R.drawable.item_)
                .fallback(R.drawable.item_);
        Glide.with(context)
                .load(url)
                .apply(options)
                .into(imageView);
    }
    @SuppressLint("CheckResult")
    public static void ImageFilletLoad(Context context, String url, ImageView imageView) {
        RequestOptions options = new RequestOptions();
        options.error(R.drawable.item_)
                .fallback(R.drawable.item_);
        Glide.with(context)
                .load(url)
                .apply(options)
                .into(imageView);
    }

    @SuppressLint("CheckResult")
    public static void ImageBannerLoad(Context context, String url, ImageView imageView) {
//        RequestOptions options = new RequestOptions();
//        options.error(R.drawable.banner_error)
//                .fallback(R.drawable.banner_error);
//        Glide.with(context)
//                .load(url)
//                .apply(options)
//                .into(imageView);
    }

    public static void ImageLoad(Context context, File file, ImageView imageView) {
//        RoundedCorners roundedCorners= new RoundedCorners(90);
//        RequestOptions options = RequestOptions.bitmapTransform(roundedCorners).override(300, 300);
        Glide.with(context)
                .load(file)
                .into(imageView);
    }
}
